package org.gesplan.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author David
 */
@Entity
@Table(name = "location_group")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "LocationGroup.findAll", query = "SELECT l FROM LocationGroup l"),
    @NamedQuery(name = "LocationGroup.findById", query = "SELECT l FROM LocationGroup l WHERE l.id = :id"),
    @NamedQuery(name = "LocationGroup.findByDescription", query = "SELECT l FROM LocationGroup l WHERE l.description = :description"),
    @NamedQuery(name = "LocationGroup.findByTableName", query = "SELECT l FROM LocationGroup l WHERE l.tableName = :tableName"),
})
public class LocationGroup implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Short id;
    @Basic(optional = false)
    @Column(name = "description")
    private String description;
    @Column(name = "table_name")
    private String tableName;
    @Column(name = "table_id")
    private String tableId;
    @Column(name = "table_description")
    private String tableDescription;    
    @OneToMany(mappedBy = "locationGroupId")
    private Collection<Location> locationCollection;

    public LocationGroup() { }

    public LocationGroup(Short id) {
        this.id = id;
    }

    public LocationGroup(Short id, String description) {
        this.id = id;
        this.description = description;
    }

    public Short getId() {
        return id;
    }

    public String getDescription() {
        return description;
    }

    public String getTableName() {
        return tableName;
    }

    public String getTableId() {
        return tableId;
    }

    public String getTableDescription() {
        return tableDescription;
    }

    @XmlTransient
    public Collection<Location> getLocationCollection() {
        return locationCollection;
    }

    public void setLocationCollection(Collection<Location> locationCollection) {
        this.locationCollection = locationCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }



    @Override
    public String toString() {
        return description;
    }
    
    
}